<template>
	<view class="content">
		<view :class="show ? 'fade-in' : 'fade-out'">
			<block v-for="(item,index) in list" :key="index">
				<view class="list">
					<view class="left">
						<view class="name">{{item.description}}</view>
						<view class="time">{{item.create_time}}</view>
					</view>
					<text class="right">{{item.money>0?'+'+item.money:item.money}}</text>
				</view>
			</block>
			<w-load-more ref="wLoadMore"></w-load-more>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				list: [],
				show: false

			};
		},
		onLoad() {
			this.getList(1)
		},
		onReachBottom() {
			if(this.list.length < 20) return
			this.page++
			this.$refs['wLoadMore'].setLoading()
			this.getList()
		},
		methods: {
			async getList(loading) {
				try {
					let result = await this.$request({
						loading,
						method: 'post',
						url: '/api/user/money_log',
						data: {
							page: this.page
						}
					})
					let data = result.data.data.data
					if (this.page == 1) {
						this.list = data
						this.show = true
					}else{
						this.list = this.list.concat(data)
						this.$refs['wLoadMore'].setNomore()
						if(data.length == 0){
							this.page--
						}
					}
				} catch (e) {
					this.msg(e.data.msg)
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		.list {
			height: 158rpx;
			border-bottom: 1px solid #e7e7e7;
			display: flex;
			align-items: center;
			justify-content: space-between;
      background: #ffffff;
      border-top: 1px solid #e7e7e7;
      padding: 15px;
			.left {
				.name {
					font-size: 32rpx;
					font-weight: 400;
					color: #333333;
				}

				.time {
					font-size: 26rpx;
					font-weight: 400;
					color: #999999;
					margin-top: 12rpx;
				}
			}

			.right {
				font-size: 32rpx;
				font-weight: bold;
				color: #333333;
			}
		}
	}
</style>
